<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类</title>
</head>
<body>
    <script>

        class A{
            //属性
            age = 18; // 为实例对象添加属性 age 
            

            //方法
            constructor(name,age){ //构造方法  『初始化对象』
                this.name = name;
                this.age = age;
                this.run = function(){
                    console.log('我可以跑酷....');
                }
            }

            //原型对象身上
            run(){
                console.log('我可以奔跑')
            }

            //函数对象  类身上
            static runs(){
                console.log('move move move');
            }

            static NAME = '我是简单的字母!!';
        }

        //继承
        class B extends A{
            //属性
            data = '我是一个子类';
            fn = () => {
                console.log('fn fn fn');
            }

            //方法
            constructor(name, age, height, weight, xingzuo){
                //子类构造方法中, 『必须要执行的函数』
                super(name, age); //调用父类的构造方法.  => 简化代码
               
                this.height=  height;
                this.weight = weight;
                this.xingzuo = xingzuo;
            }

            run() {
                console.log('向前跑');
            }

        }

        //实例化
        let b = new B('王力宏', 42, 175, 65, '摩羯座');

        console.dir(b);

        b.run();

    </script>
</body>
</html>